﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.ComponentModel;
using System.Collections;

namespace Flockmaster
{
    public class MyEventArgs : EventArgs
    {
        private int count;
        public MyEventArgs(int Count)
        {
            count = Count;
        }
        public int Count
        {
            get { return count; }
            set { count = value; }
        }
    }

    public class ErrorEventArgs : EventArgs
    {
        private string message;
        public ErrorEventArgs(string Message)
        {
            message = Message;
        }

        public string Message
        {
            get { return message; }
            set { message = value; }
        }
    }

    public enum MessageTypes : int
    {
        ReportsProgress = -1,
        ErrorMessage = -2
    }

    /// <summary>
    /// 数据库类型
    /// </summary>
    public enum DBTypes : int
    {
        SqlServer = 0,
        MySql = 1,
        Oracle = 2,
        SQLCE = 3,
        Access = 4
    };

    public enum DBConnType : int
    {
        SrcConnection=0,
        DestConnection=1,
        SysConnection=2
    }

    public interface IDatabaseCopy
    {
        event EventHandler<MyEventArgs> ReportsProgress;
        event EventHandler<MyEventArgs> End;
        event EventHandler<ErrorEventArgs> ReceiveErrorMeaaage;

        IDbConnection DestConnection { get; set; }
        IDbConnection SrcConnection { get; set; }
        IDbConnection SysConnection { get; set; }
        bool ISStop { get; set; }
        int Count { get; set; }
        DBTypes GetSrcType { get; set; }
        DBTypes GetDestType { get; set; }

        void CreateConn(string IpAddress, string Username, string Password, string Database, DBTypes m_dbType, DBConnType Conn);

        void CreateSysConn(string IpAddress, string Username, string Password, DBTypes m_dbType);

        void CreateSysConn(string IpAddress, string Username, string Password, DBTypes m_dbType, string ServieName);

        int GetRowsCount(string TableName);

        bool DoesTableExist(string TableName, DBTypes m_dbType);

        void DropTable(string TableName);

        ArrayList GetDataBaseList(IDbConnection Conn, DBTypes dbType);
        ArrayList GetTableList(string Database, DBTypes dbType, string username);

        ArrayList GetTableList(string Database, DBTypes dbType);

        ArrayList GetTableList(DBTypes dbType);

        ArrayList GetColumnList(string TableName, DBTypes dbType, string username);

        void StopCopySession();

        void CopyTable(SendCmd Message);
    }
}
